/*
 * shadowBox 1.0 - jQuery plugin
 *
 * Copyright (c) 2008 Oleg Slobodskoi
 *
 */
(function($) {

	//defaults
	var d = {
		imageDir: 'img/',
		cornerTopLeft: {
			width: 7,
			height: 10,
			fileName: 'corner-tl.png'
		},
		cornerTopRight: {
			width: 7,
			height: 10,
			fileName: 'corner-tr.png'
		},
		cornerBottomLeft: {
			width: 8,
			height: 11,
			fileName: 'corner-bl.png'
		},
		cornerBottomRight: {
			width: 8,
			height: 11,
			fileName: 'corner-br.png'
		},
		left: {
			width: 5,
			fileName: 'left.png'
		},
		right: {
			width: 5,
			fileName: 'right.png'
		},
		top: {
			height: 10,
			fileName: 'top.png'
		},
		bottom: {
			height: 9,
			fileName: 'bottom.png'
		}


	};

	


 	$.fn.shadowBox = function(s)
	{
		$.extend( d, s );
	
	
	
		var	self = this,
			width = $(this).width(),
			height = $(this).height(),
			shadowBox,
			content = $(this).html()
		;
		
		shadowBox = $('<div class="shadow-box"/>').
		css({
			width: width,
			height: height,
			position: 'absolute'
		});
		self.html(shadowBox);
		
		$('<div class="shadow-box-content">').css({
			position: 'absolute',
			top: 0,
			left: 0,
			width: '100%',
			height: '100%'
			
		}).
		html(content).
		appendTo(shadowBox);

		
		//cornerTopLeft
		$('<img/>').
			attr({
				src: d.imageDir+d.cornerTopLeft.fileName
			}).
			css({
				'position': 'absolute',
				'left': d.left.width*-1,
				'top': d.cornerTopLeft.height*-1
			}).
			appendTo(shadowBox);	
	
		//cornerTopRight
		$('<img/>').
			attr({
				src: d.imageDir+d.cornerTopRight.fileName
			}).
			css({
				'position': 'absolute',
				'right':  d.right.width*-1,
				'top': d.cornerTopRight.height*-1
			}).
			appendTo(shadowBox);
		
		//cornerBottomLeft
		$('<img/>').
		attr({
			src: d.imageDir+d.cornerBottomLeft.fileName
		}).
		css({
			'position': 'absolute',
			'left': d.left.width*-1,
			'bottom': d.cornerBottomLeft.height*-1
		}).
		appendTo(shadowBox);
		
		//cornerBottomRight
		$('<img/>').
		attr({
			src: d.imageDir+d.cornerBottomRight.fileName
		}).
		css({
			'position': 'absolute',
			'right': d.right.width*-1,
			'bottom': d.cornerBottomRight.height*-1
		}).
		appendTo(shadowBox);
		
		//top
		$('<img/>').
		attr({
			src: d.imageDir+d.top.fileName
		}).
		css({
			'position': 'absolute',
			'top': d.top.height*-1,
			'left': d.cornerTopLeft.width-d.left.width,
			'width': width-4,
			'height': d.top.height
		}).
		appendTo(shadowBox);
		
		//left
		$('<img/>').
		attr({
			src: d.imageDir+d.left.fileName
		}).
		css({
			'position': 'absolute',
			'top': 0,
			'left': d.left.width*-1,
			'width': d.left.width,
			'height': height
		}).
		appendTo(shadowBox);	
		
		//right
		$('<img/>').
		attr({
			src: d.imageDir+d.right.fileName
		}).
		css({
			'position': 'absolute',
			'top': 0,
			'right': d.right.width*-1,
			'width': d.right.width,
			'height': height
		}).
		appendTo(shadowBox);	
	
		//bottom
		$('<img/>').
		attr({
			src: d.imageDir+d.bottom.fileName
		}).
		css({
			'position': 'absolute',
			'bottom': d.cornerBottomLeft.height*-1,
			'left': d.cornerBottomRight.width-d.left.width,
			'width': width-d.left.width-1,
			'height': d.bottom.height
		}).
		appendTo(shadowBox);	
		

	};//end of $.fn.shadowBox
	
	

})( jQuery );	